page.tsx 733 B

1234567891011121314151617181920212223242526272829
  1. import { notFound, forbidden } from 'next/navigation';
  2. import { fetchFeedPost, fetchFeedReplies } from '@/lib/api/feed/post';
  3. import FeedPostView from './_component/FeedPostView';
  4. export default async function FeedPostPage({ params }: { params: Promise<{ postID: string }> }) {
  5. const { postID } = await params;
  6. if (!/^\d+$/.test(postID)) {
  7. return forbidden();
  8. }
  9. const id = Number(postID);
  10. const [postRes, repliesRes] = await Promise.all([
  11. fetchFeedPost(id),
  12. fetchFeedReplies(id, 1, 30)
  13. ]);
  14. if (!postRes.success || !postRes.data) {
  15. return notFound();
  16. }
  17. return (
  18. <FeedPostView
  19. post={postRes.data}
  20. initialReplies={repliesRes.data?.list ?? []}
  21. initialRepliesTotal={repliesRes.data?.total ?? 0}
  22. />
  23. );
  24. }